package com.rgs.component;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.AnnotationBeanNameGenerator;
import org.springframework.stereotype.Component;

/**
 * @author rgsmaster
 * @date 2024/8/6 14:52
 * @description
 */
@Component
public class MyBeanNameComponent extends AnnotationBeanNameGenerator {

    @Override
    protected String buildDefaultBeanName(BeanDefinition definition) {
        //源码逻辑，默认使用类名首字母小写作为bean的名字
//        String beanClassName = definition.getBeanClassName();
//        Assert.state(beanClassName != null, "No bean class name set");
//        String shortClassName = ClassUtils.getShortName(beanClassName);
//        return Introspector.decapitalize(shortClassName);

        //自己重写，使用类的全限定类名作为bean的名字
        return definition.getBeanClassName();
    }
}
